package com.ss.android.topic.e;

import com.bytedance.frameworks.baselib.network.http.util.HttpQueryHelper;
import com.bytedance.retrofit2.client.Request;
import com.bytedance.retrofit2.RequestBuilder;
import com.bytedance.retrofit2.ResponseWrapper;
import com.bytedance.ttnet.c.SsOkHttpClient;
import com.ss.android.article.common.http.ApiError;
import com.ss.android.article.common.http.ApiResponse;

public final class aa extends SsOkHttpClient {
    public aa() {

    }

    public final void intercept(Request request, ResponseWrapper responseWrapper) throws Throwable {
        super.intercept(request, responseWrapper);
        if(responseWrapper != null) {
            Object v1 = responseWrapper.body;
            if((v1 instanceof ApiResponse)) {
                int v0 = ((ApiResponse)v1).getErrorCode();
                if(v0 > 0) {
                    throw new ApiError(v0, ((ApiResponse)v1).getErrorTips());
                }
            }
        }
    }

    public final void intercept(RequestBuilder requestBuilder) {
        super.intercept(requestBuilder);
        if(requestBuilder != null) {
            String v0 = requestBuilder.url;
            if(!android.support.design.a.isTextEmpty(v0) && (v0.contains("/wenda/v1/"))) {
                HttpQueryHelper v1 = new HttpQueryHelper(v0);
                v1.put("wd_version", "1");
                requestBuilder.url = v1.getEncodeQuery();
            }
        }
    }
}

